import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;

import javax.swing.JOptionPane;

import fit.ActionFixture;

import Controllers.GlobalData;
import Controllers.RequestManager;
import Controllers.GenericToolsForController.RequestMainStatusEnum;
import Controllers.GenericToolsForController.RequestStepStatusEnum;
import Controllers.GenericToolsForController.WorkerPostion;
import Entity.Request;
import Entity.RequestStatusHistory;
import Entity.Status;
import Entity.User;
import Entity.Worker;
import ICM_OCSF.Client;

public class ResumeRequest extends ActionFixture{
	int examinerId;
	int requestId;
	private static String LocalNetworkConfigurtaion = "ConfigServerOption.txt";
	public Request request;
	public Client client;
	public boolean testresult;
	List<Request> requestsList;
	Worker examiner_90,ICM_2;
	public ResumeRequest(){
		
	}

		public void enterToSystem()
		{
			/*
			  in the System we have:
			  initiator  -  id 3
			  2 inspectors shimon1171 - id 62, guyp = id 2.
			  There are 5 request:
				request No 11, here inspector are shimon1171 , the Ststus is: OPEN, REV_REVIEWED_CLOSE.
				request No 12, here inspector are shimon1171 , the Ststus is: OPEN, TST_PASSED.
				request No 13, here inspector are shimon1171 , the Ststus is: OPEN, EXE_PASSED.
				
			 */
			
			Request req;
			requestsList = new ArrayList<Request>();
			
			
			examiner_90 = new Worker(1, 90, "shimon", "Arzuan", "icmbraudesys@gmail.com", "0508-1234567", "shimon1171", "2" );
			ICM_2 = new Worker(2, 2, "guy", "peleg", "icmbraudesys@gmail.com", "0508-1234567", "guyp", "1" );
			User initiator = new User(3, "Ron", "Rosesnfeld","icmbraudesys@gmail.com", "0508-1234567", "roon", "Student");		

			//the current worker that log to the system
			
					
			req = new Request();
			req.setExaminer(examiner_90);
			req.setRequestId(11);
			req.setInspector(examiner_90);
			req.setInitiator(initiator);
			Status status = new Status(RequestStepStatusEnum.EXE_PASSED, RequestMainStatusEnum.SUSPEND); 
			RequestStatusHistory cureentStatus = new RequestStatusHistory(1, status, new Date(), new Date(), null, null, null);
			req.setCurrentStatus(cureentStatus);
			requestsList.add(req);
			
			
			req = new Request();
			req.setRequestId(12);
			req.setExaminer(ICM_2);
			req.setInspector(examiner_90);
			req.setInitiator(initiator);
			status = new Status(RequestStepStatusEnum.EXE_PASSED, RequestMainStatusEnum.OPEN); 
			cureentStatus = new RequestStatusHistory(2, status, new Date(), new Date(), null, null, null);
			req.setCurrentStatus(cureentStatus);
			requestsList.add(req);
			
			
			req = new Request();
			req.setRequestId(13);
			req.setInspector(examiner_90);
			req.setExaminer(examiner_90);
			req.setInitiator(initiator);
			status = new Status(RequestStepStatusEnum.EXE_PASSED, RequestMainStatusEnum.OPEN); 
			cureentStatus = new RequestStatusHistory(3, status, new Date(), new Date(), null, null, null);
			req.setCurrentStatus(cureentStatus);
			requestsList.add(req);
			
			
			
			
		}
		
		public void requestNumber(int number)
		{
			this.requestId = number;
		}
		
		public void workerId(int number)
		{
			if (number == 2)
				GlobalData.worker = ICM_2;
			else
				GlobalData.worker = examiner_90;
			this.examinerId = number;
		}
	
		
		public void resultTest(boolean testres)
		{
			this.testresult = testres;
		}
		
		
		public boolean resumeRequest()
		{
			/*Status [] sts= {
					new Status(RequestStepStatusEnum.EXE_PASSED,RequestMainStatusEnum.OPEN),
					new Status(RequestStepStatusEnum.TST_UTESTED_EXTENDED,RequestMainStatusEnum.OPEN),
					new Status(RequestStepStatusEnum.TST_UTESTED_EXTENDED_DENY,RequestMainStatusEnum.OPEN),
					new Status(RequestStepStatusEnum.TST_UTESTED_TIME_EXTENSION_PENDING,RequestMainStatusEnum.OPEN)	};*/
		//	List<Request> requestToChoose = RequestManager.getInstance().getAllRequestToBeTested(this.examinerId, WorkerPostion.EXAMINER, sts);
					
			for(Request req : requestsList)
			{
				if(req.getRequestId() == requestId)
				if (testresult==true)
					return req.resume(0);
			}
			return false;
			
		}
}